linstor: test VM startup on disk failure - #595
Conversation
|
Leaving this PR as draft for now since this test requires starting in a clean environment (with no LINSTOR SR already set-up) since it needs to set up the I would have hoped that placing this test in its own sub-package ( @glehmann I believe this is what #558 was trying to fix for the |
Have you seen that in pkgfixtures.py? # Due to a bug in the way pytest handles the setup and teardown of package-scoped fixtures,
# we moved the following fixtures out of the main conftest.py.
# To workaround the bug, the fixture must be imported either in a package's own conftest.py,
# or directly in a test module. Then the fixtures will truly be handled as package-scoped.
# Reference: https://github.com/pytest-dev/pytest/issues/8189It might be worth trying if it helps
The case is a bit different in #558: we want the fixtures to not be there when running the create/destroy tests. |
I tried the following:
But pytest comes up with the following plan: As you can see, it just duplicates teardown for those package-scoped fixtures. I think pytest performs teardown on package-scoped fixtures when all tests from the package and sub-packages ran, but not when it starts running tests of a sub-package. Maybe the "simpler" approach here would be to extract the bulk of the logic for creating the LVM volume and LINSTOR SR into their own files in
I believe both problems are somewhat related? Only tested on the LINSTOR SR tests - I observed that if a test, that uses a fixture that creates a LINSTOR SR, runs before the My understanding of #558 was that teardown of package-scoped fixtures was supposed to be performed when entering a sub-package, which would solve this problem. Is that correct? This can be easily replicated by:
|
This extracts the `host_devices` function of the `lvm_disks` fixture in the LINSTOR SR tests into its own fixture. This allows getting the paths to the physical disks used in the LVM volume in other fixtures and the tests, and overriding those paths in sub-packages. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
This moves out the regular LINSTOR SR tests into its own `tests/storage/linstor/regular` package to remove all tests from the `linstor` package. Package-scoped fixtures were also moved to their own `pkgfixtures.py` file and are explicitly imported into each `conftest.py` file of the sub-packages. This is done because we need to make sure the setup and teardown of those fixtures execute when crossing a sub-package boundary, which does not happen when a package wants to use a fixture from a parent package. This follows how the problem has been fixed in the root `conftest.py` file. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
42217f2 to
73b6b8b
Compare
|
As seen with @glehmann yesterday, I split the LINSTOR SR tests into separate sub-packages to work around the issue of package-scoped fixtures not doing the setup/teardown sequence when crossing a sub-package boundary when they are declared in the parent package Marking this PR as ready for review since this was the last blocking topic for me. CI seems to be currently failing for reasons unrelated to this PR. |
| return wait_for(fn, msg, timeout_secs, retry_delay_secs, True) | ||
|
|
||
| def run_with_timeout(fn: Callable[[], Any], timeout_secs: int = 2 * 60) -> None: | ||
| queue = multiprocessing.Queue() |
There was a problem hiding this comment.
| queue = multiprocessing.Queue() | |
| queue: multiprocessing.Queue[Exception] = multiprocessing.Queue() |
| vm.wait_for_os_booted() | ||
| vm.shutdown(verify=True) | ||
| finally: | ||
| flakey_unused_512B_disk[random_host].repair() |
There was a problem hiding this comment.
Using defer(lambda: flakey_unused_512B_disk[random_host].repair()) line 36 would avoid the try/finally block and keep the disk in its failed state in the debugger, in case of failure
| ) -> None: | ||
| sr = linstor_sr | ||
| vm = vm_on_linstor_sr | ||
| random_host = random.choice(sr.pool.hosts) |
There was a problem hiding this comment.
Introducing randomness might make the test less stable. Is there a reason to pick the host randomly?
There was a problem hiding this comment.
I have no reasons myself, this is more of an artifact from the previous PR. The test should be successful on all hosts equally.
We can either fix this to e.g. the first host of the list, or fail the disk and do the test on all hosts one-by-one if we want to be thorough (if we're ready to pay the extra time complexity, which would be
There was a problem hiding this comment.
Using the first host is fine IMO
| logging.info(f'Repairing device {self._device.path} on {self._host.hostname_or_ip}') | ||
|
|
||
| self._apply_dm_table(self._build_dm_table(False)) | ||
| cmd_res = self._host.ssh('linstor -m --controllers `xe host-list params=address --minimal` r l -n `hostname` --props DrbdOptions/SkipDisk') # noqa: E501 |
There was a problem hiding this comment.
You can just split the line instead of disabling the E501 rule
| cmd_res = self._host.ssh('linstor -m --controllers `xe host-list params=address --minimal` r l -n `hostname` --props DrbdOptions/SkipDisk') # noqa: E501 | |
| cmd_res = self._host.ssh('linstor -m --controllers `xe host-list params=address --minimal` r l' | |
| ' -n `hostname` --props DrbdOptions/SkipDisk') |
This adds the `run_with_timeout` helper function that can be used to call blocking functions with a timeout to avoid the tests potentially hanging indefinitely. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
73b6b8b to
904bb05
Compare
904bb05 to
a53257f
Compare
|
Marking this as draft again since more extensive testing shows that this test sometimes ends up in a split-brain on the DRBD side. |
a53257f to
b5d6c9d
Compare
This adds a test to the LINSTOR SR test suite to make sure that a VM with a VDI on a shared LINSTOR SR can still start and shut down properly when a physical disk of that SR has failed. The test does the following: - Fails a physical disk of the LINSTOR SR pool on a random host. - Ensures a VM can still start up and shut down on all hosts. This uses a device mapper to avoid relying on the capabilities of the underlying block device. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
b5d6c9d to
73b7044
Compare
This adds a test to the LINSTOR SR test suite to make sure that a with a VDI on a shared LINSTOR SR can still start and shut down when a physical disk of that SR has failed.
The test does the following:
This uses a device mapper to avoid relying on the capabilities of underlying block device.
Supersedes #312.